<template>
  <div>
    <div class="headHint">基本信息</div>
    <el-form
      ref="basicForm"
      :model="basicForm"
      :rules="rules"
      label-width="100px"
      style="width:600px;"
    >
      <el-form-item label="活动名称" prop="name">
        <el-input v-model="basicForm.name" placeholder="活动名称"/>
      </el-form-item>
      <el-form-item label="开始时间" required prop="startTime">
        <el-date-picker
          :picker-options="pickerOptions0"
          v-model="basicForm.startTime"
          type="datetime"
          placeholder="选择日期"
          style="width: 100%;"
        />
      </el-form-item>
      <el-form-item label="结束时间" required prop="endTime">
        <el-date-picker
          :picker-options="pickerOptions1"
          v-model="basicForm.endTime"
          type="datetime"
          placeholder="选择日期"
          style="width: 100%;"
        />
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="basicForm.memo" placeholder="备注"/>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  props: {
    basicForm: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      rules: {
        name: [
          { required: true, message: '请选择活动名称', trigger: 'change' }
        ],
        startTime: [
          { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
        ],
        endTime: [
          { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
        ]
      },
      pickerOptions0: {
        disabledDate: (time) => {
          if (this.basicForm.endTime !== '' && this.basicForm.endTime != null) {
            return time.getTime() < Date.now() || time.getTime() > this.basicForm.endTime
          } else {
            return time.getTime() < Date.now()
          }
        }
      },
      pickerOptions1: {
        disabledDate: (time) => {
          return time.getTime() < this.basicForm.startTime || time.getTime() < Date.now()
        }
      }
    }
  },
  methods: {
  }
}
</script>
<style lang="scss" scoped>
.headHint {
  color: rgb(52, 172, 228);
  padding: 10px 30px;
  background: #f0f3ff;
  margin: 20px 0;
  overflow: hidden;
}
</style>

